﻿
@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <link href="~/Areas/Back/lib/layui/css/layui.css" rel="stylesheet" />
    <script src="~/Areas/Back/lib/layui/layui.js"></script>
    <title>新增新闻分类</title>
</head>
<body>
    <div class="layui-container" style="margin-top:50px;margin-bottom:150px;">
        @* onsubmit="return false" 禁止form表单提交，我们要用ajax  *@
        <form class="layui-form" id="addForm" onsubmit="return false">
            @* 标题 *@
            <div class="layui-form-item">
                <label class="layui-form-label">标题</label>
                <div class="layui-input-block">
                    <input type="text" id="Name" class="layui-input" placeholder="请输入名字" />
                </div>
            </div>
            @*提交和重置按钮*@
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit lay-filter="subAdd"> 立即提交</button>
                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                </div>
            </div>
        </form>
    </div>
</body>
<script>
    layui.use(['form', 'layedit', 'upload'], function () {
        var form = layui.form;
        var layedit = layui.layedit;
        var layer=layui.layer;
        //加载图片上传模块
        var upload = layui.upload;
        var $ = layui.$;
        //开始处理点击提交
        form.on('submit(subAdd)', function () {
            //ajax 请求
            $.ajax({
                url: "AddDel",
                method: "post",
                dataType: "json",
                data: {
                    Name: $("#Name").val()
                },
                success: function (res) {
                    if (res.success == true) {
                        layer.msg(res.msg);
                        //关闭当前窗口，并且刷新列表
                        //1.获取弹窗的编号
                        var index = parent.layer.getFrameIndex(window.name);
                        //2.关闭窗口
                        parent.layer.close(index);
                        //3.刷新父级页面
                        parent.location.reload();
                    } else {
                        layer.msg(res.msg);
                    }
                }
            });
            return false;
        });
    });
</script>
</html>

